<?php
class GuildCompetitionHistoryVo extends SzAbstractMySqlVo
{

    private $guildId;
    private $gold;
    private $silver;
    private $bronze;
    private $highest;
    private $createTime;
    private $updateTime;
    private $endTime;

    /**
     * Initialize GuildCompetitionHistoryVo.
     *
     * @param $guildId
     * @param $gold
     * @param $silver
     * @param $bronze
     * @param $highest
     * @param $createTime
     * @param $updateTime
     * @param $endTime
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return GuildCompetitionHistoryVo
     */
    public function __construct($guildId, $gold, $silver, $bronze, $highest, $createTime, $updateTime, $endTime, $isInsert = false) {
        $this->guildId = $guildId;
        $this->gold = json_decode($gold, true);
        $this->silver = json_decode($silver, true);
        $this->bronze = json_decode($bronze, true);
        $this->highest = $highest;
        $this->createTime = $createTime;
        $this->updateTime = $updateTime;
        $this->endTime = $endTime;

        $this->isInsert = $isInsert;
        $this->voClassName = 'GuildCompetitionHistoryVo';
        $this->ormName = 'GuildCompetitionHistory';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'guildId' => $this->getGuildId(),
            'gold' => ($needEncode) ? $this->getGold() : $this->getRawGold(),
            'silver' => ($needEncode) ? $this->getSilver() : $this->getRawSilver(),
            'bronze' => ($needEncode) ? $this->getBronze() : $this->getRawBronze(),
            'highest' => $this->getHighest(),
            'createTime' => $this->getCreateTime(),
            'updateTime' => $this->getUpdateTime(),
            'endTime' => $this->getEndTime(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'guildId' => $this->getGuildId(),
            'gold' => ($needEncode) ? $this->getGold() : $this->getRawGold(),
            'silver' => ($needEncode) ? $this->getSilver() : $this->getRawSilver(),
            'bronze' => ($needEncode) ? $this->getBronze() : $this->getRawBronze(),
            'highest' => $this->getHighest(),
            'createTime' => $this->getCreateTime(),
            'updateTime' => $this->getUpdateTime(),
            'endTime' => $this->getEndTime(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getGuildId(),
            $this->getGold(),
            $this->getSilver(),
            $this->getBronze(),
            $this->getHighest(),
            $this->getCreateTime(),
            $this->getUpdateTime(),
            $this->getEndTime(),
        );
    }

    public function getGuildId()
    {
        return $this->guildId;
    }

    public function setGuildId($val)
    {
        $this->saveColumnStatus(0, $this->guildId);
        $this->guildId = $val;
    }

    public function getGold()
    {
        return json_encode($this->gold);
    }

    public function getRawGold()
    {
        return $this->gold;
    }

    public function setGold($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 25600) {
            SzLogger::get()->error('[GuildCompetitionHistoryVo] The length of column gold exceed the limit, length / limit: ' . $encodedLength . ' / 25600');
            throw new SzException(10522, array('GuildCompetitionHistoryVo', '25600', $encodedLength));
        } else if ($encodedLength > 23040) {
            SzLogger::get()->warn('[GuildCompetitionHistoryVo] The length of column gold exceed the warning level, length / limit: ' . $encodedLength . ' / 25600');
        }
        $this->saveColumnStatus(1, $this->gold);
        $this->gold = $val;
    }

    public function getSilver()
    {
        return json_encode($this->silver);
    }

    public function getRawSilver()
    {
        return $this->silver;
    }

    public function setSilver($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 25600) {
            SzLogger::get()->error('[GuildCompetitionHistoryVo] The length of column silver exceed the limit, length / limit: ' . $encodedLength . ' / 25600');
            throw new SzException(10522, array('GuildCompetitionHistoryVo', '25600', $encodedLength));
        } else if ($encodedLength > 23040) {
            SzLogger::get()->warn('[GuildCompetitionHistoryVo] The length of column silver exceed the warning level, length / limit: ' . $encodedLength . ' / 25600');
        }
        $this->saveColumnStatus(2, $this->silver);
        $this->silver = $val;
    }

    public function getBronze()
    {
        return json_encode($this->bronze);
    }

    public function getRawBronze()
    {
        return $this->bronze;
    }

    public function setBronze($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 25600) {
            SzLogger::get()->error('[GuildCompetitionHistoryVo] The length of column bronze exceed the limit, length / limit: ' . $encodedLength . ' / 25600');
            throw new SzException(10522, array('GuildCompetitionHistoryVo', '25600', $encodedLength));
        } else if ($encodedLength > 23040) {
            SzLogger::get()->warn('[GuildCompetitionHistoryVo] The length of column bronze exceed the warning level, length / limit: ' . $encodedLength . ' / 25600');
        }
        $this->saveColumnStatus(3, $this->bronze);
        $this->bronze = $val;
    }

    public function getHighest()
    {
        return $this->highest;
    }

    public function setHighest($val)
    {
        $this->saveColumnStatus(4, $this->highest);
        $this->highest = $val;
    }

    public function getCreateTime()
    {
        return $this->createTime;
    }

    public function setCreateTime($val)
    {
        $this->saveColumnStatus(5, $this->createTime);
        $this->createTime = $val;
    }

    public function getUpdateTime()
    {
        return $this->updateTime;
    }

    public function setUpdateTime($val)
    {
        $this->saveColumnStatus(6, $this->updateTime);
        $this->updateTime = $val;
    }

    public function getEndTime()
    {
        return $this->endTime;
    }

    public function setEndTime($val)
    {
        $this->saveColumnStatus(7, $this->endTime);
        $this->endTime = $val;
    }

}